RedBoxClipEvent

Kind of class:public class
Package:com.smartfoxserver.redbox.events
Inherits from:SFSEvent
Dispatched by:
Author:The gotoAndPlay() Team
http://www.smartfoxserver.com
http://www.gotoandplay.it
Classpath:com.smartfoxserver.redbox.events.RedBoxClipEvent
File last modified:Monday, 25 February 2008, 11:20:49
RedBoxClipEvent is the class representing all events dispatched by the RedBox's AVClipManager instance.
The RedBoxClipEvent extends the SFSEvent class, which in turn extends the flash.events.Event class.
SFSEvent also provides a public property called params of type Object that can contain any number of parameters.
Usage:
  • Please refer to the specific events for usage examples and params object content.

Summary


Event handlers
  • onAVConnectionInited : String
    • Dispatched when the connection to Red5 server has been established.
  • onAVConnectionError : String
    • Dispatched when the connection to Red5 server can't be established.
  • onClipList : String
    • Dispatched when clips list is returned, in response to a AVClipManager.getClipList request.
  • onClipRecordingStarted : String
    • Dispatched when the recording af an a/v clip starts, in response to a AVClipManager.startClipRecording request.
  • onClipSubmissionFailed : String
    • Dispatched when an error occurs in the RedBox server-side extension after submitting an a/v clip.
  • onClipAdded : String
    • Dispatched when a new a/v clip has been submitted by one of the users in the current zone.
  • onClipDeleted : String
    • Dispatched when an a/v clip has been deleted by one of the users in the current zone.
  • onClipUpdated : String
    • Dispatched when the properties of an a/v clip have been updated by one of the users in the current zone.

Event handlers

onAVConnectionError

public static const onAVConnectionError:String = "onAVConnectionError"
(read)

Dispatched when the connection to Red5 server can't be established.
This event is dispatched when an error or special condition (like "connection closed") occurred in the flash.net.NetConnection object used internally by the AVClipManager to handle the connection to Red5.
This kind of error is always related to the Red5 server connection, so you should check if the server is running and reachable.
Also check the Red5 logs or console output for more details.

The params object contains the following parameters.
Parameters:
errorCode:
(String) the description of the error condition; check the "code" property of the NetStatusEvent.info object in the Actionscript 3 Language Reference.
Example:
  • The following example shows how to handle a Red5 connection error.
    avClipMan.addEventListener(RedBoxClipEvent.onAVConnectionError, onAVConnectionError)
    
    function onAVConnectionError(evt:RedBoxClipEvent):void
    {
        trace("A connection error occurred: " + evt.params.errorCode)
    }

onAVConnectionInited

public static const onAVConnectionInited:String = "onAVConnectionInited"
(read)

Dispatched when the connection to Red5 server has been established.
This event is dispatched after the AVClipManager is instantiated or when the AVClipManager.initAVConnection method is called.
The connection to Red5 must be available before any method related to a/v streaming is called.

No parameters are provided.
Example:
  • The following example shows how to handle the "onAVConnectionInited" event.
    var red5IpAddress:String = "127.0.0.1"
    var avClipMan:AVClipManager = new AVClipManager(smartFox, red5IpAddress)
    
    avClipMan.addEventListener(RedBoxClipEvent.onAVConnectionInited, onAVConnectionInited)
    
    function onAVConnectionInited(evt:RedBoxClipEvent):void
    {
        trace("Red5 connection established")
    }

onClipAdded

public static const onClipAdded:String = "onClipAdded"
(read)

Dispatched when a new a/v clip has been submitted by one of the users in the current zone.

The params object contains the following parameters.
Parameters:
clip:
(Clip) the Clip instance representing the added a/v clip.
Example:
  • The following example shows how to handle a clip added event.
    avClipMan.addEventListener(RedBoxClipEvent.onClipAdded, onClipAdded)
    
    function onClipAdded(evt:RedBoxClipEvent):void
    {
        var clip:Clip = evt.params.clip
    
        trace("A new clip was submitted")
        trace ("Clip id:", clip.id)
        trace ("Clip submitter:", clip.username)
        trace ("Clip size:", clip.size + " bytes")
        trace ("Clip last modified date:", clip.lastModified)
        trace ("Clip properties:")
        for (var s:String in clip.properties)
            trace (s, "-->", clip.properties[s])
    }

onClipDeleted

public static const onClipDeleted:String = "onClipDeleted"
(read)

Dispatched when an a/v clip has been deleted by one of the users in the current zone.

The params object contains the following parameters.
Parameters:
clip:
(Clip) the Clip instance representing the deleted a/v clip.
Example:
  • The following example shows how to handle a clip deletion event.
    avClipMan.addEventListener(RedBoxClipEvent.onClipDeleted, onClipDeleted)
    
    avClipMan.deleteClip(clipId)
    
    function onClipDeleted(evt:RedBoxClipEvent):void
    {
        trace("The clip " + evt.params.clip.id + " was deleted")
    }

onClipList

public static const onClipList:String = "onClipList"
(read)

Dispatched when clips list is returned, in response to a AVClipManager.getClipList request.

The params object contains the following parameters.
Parameters:
clipList:
(Array) a list of Clip objects for the zone logged in by the user.
Example:
  • The following example shows how to request the available clips list.
    avClipMan.addEventListener(RedBoxClipEvent.onClipList, onClipList)
    
    avClipMan.getClipList()
    
    function onClipList(evt:RedBoxClipEvent):void
    {
        for each (var clip:Clip in evt.params.clipList)
    {
            trace ("Clip id:", clip.id)
            trace ("Clip submitter:", clip.username)
            trace ("Clip size:", clip.size + " bytes")
            trace ("Clip last modified date:", clip.lastModified)
            trace ("Clip properties:")
            for (var s:String in clip.properties)
                trace (s, "-->", clip.properties[s])
        }
    }

onClipRecordingStarted

public static const onClipRecordingStarted:String = "onClipRecordingStarted"
(read)

Dispatched when the recording af an a/v clip starts, in response to a AVClipManager.startClipRecording request.

No parameters are provided.
Example:
  • The following example shows how to handle the "onClipRecordingStarted" event.
    avClipMan.addEventListener(RedBoxClipEvent.onClipRecordingStarted, onClipRecordingStarted)
    
    avClipMan.startClipRecording(true, true)
    
    function onClipRecordingStarted(evt:RedBoxClipEvent):void
    {
        // Attach camera output to video instance on stage to see what I'm recording
        video.attachCamera(Camera.getCamera())
    }

onClipSubmissionFailed

public static const onClipSubmissionFailed:String = "onClipSubmissionFailed"
(read)

Dispatched when an error occurs in the RedBox server-side extension after submitting an a/v clip.
This event is used when either a recorded or an uploaded clip is submitted.

The params object contains the following parameters.
Parameters:
error:
(String) the error message sent by the RedBox extension.
Example:
  • The following example shows how to handle a clip submission error.
    avClipMan.addEventListener(RedBoxClipEvent.onClipSubmissionFailed, onClipSubmissionFailed)
    
    var clipProperties:Object = {}
    clipProperties.author = "jack"
    
    avClipMan.submitRecordedClip(clipProperties)
    
    function onClipSubmissionFailed(evt:RedBoxClipEvent):void
    {
        trace("An error occurred during clip submission:", evt.params.error)
    }

onClipUpdated

public static const onClipUpdated:String = "onClipUpdated"
(read)

Dispatched when the properties of an a/v clip have been updated by one of the users in the current zone.

The params object contains the following parameters.
Parameters:
clip:
(Clip) the Clip instance representing the updated a/v clip.
Example:
  • The following example shows how to handle an update in clip properties.
    avClipMan.addEventListener(RedBoxClipEvent.onClipUpdated, onClipUpdated)
    
    var newClipProperties:Object = {}
    newClipProperties.title = "Batman - The Dark Knight"
    newClipProperties.author = "Warner Bros."
    
    avClipMan.updateClipProperties(clipId, newClipProperties)
    
    function onClipUpdated(evt:RedBoxClipEvent):void
    {
        trace("Clip properties have been updated")
        var clip:Clip = evt.params.clip
    
        // Update the clip list
        ...
    }